/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author damfercer
 */
@Entity
@Table(name = "linea_factura_multimarca", catalog = "corporate", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "LineaFacturaMultimarca.findAll", query = "SELECT l FROM LineaFacturaMultimarca l"),
    @NamedQuery(name = "LineaFacturaMultimarca.findByIdLineaFacturaMultimarca", query = "SELECT l FROM LineaFacturaMultimarca l WHERE l.idLineaFacturaMultimarca = :idLineaFacturaMultimarca"),
    @NamedQuery(name = "LineaFacturaMultimarca.findByFactura", query = "SELECT l FROM LineaFacturaMultimarca l WHERE l.factura = :factura"),
    @NamedQuery(name = "LineaFacturaMultimarca.findCantidadEnviadaDeProductoTallaYPedido", query = "SELECT SUM(l.cantidad) FROM LineaFacturaMultimarca l, FacturaMultimarca f WHERE l.factura=f AND f.pedido.idPedido=:idPedido AND l.productoTalla.idProductoTalla=:idProductoTalla"),    
    @NamedQuery(name = "LineaFacturaMultimarca.findCantidadEnviadaDeProductoTallaYPedidoYNoFactura", query = "SELECT SUM(l.cantidad) FROM LineaFacturaMultimarca l, FacturaMultimarca f WHERE l.factura=f AND f.pedido.idPedido=:idPedido AND l.productoTalla.idProductoTalla=:idProductoTalla AND NOT l.factura.idFacturaMultimarca=:idFactura"),    
    @NamedQuery(name = "LineaFacturaMultimarca.findByProductoTalla", query = "SELECT l FROM LineaFacturaMultimarca l WHERE l.productoTalla = :productoTalla"),
    @NamedQuery(name = "LineaFacturaMultimarca.findByCantidad", query = "SELECT l FROM LineaFacturaMultimarca l WHERE l.cantidad = :cantidad"),
    @NamedQuery(name = "LineaFacturaMultimarca.findByCoste", query = "SELECT l FROM LineaFacturaMultimarca l WHERE l.coste = :coste"),
    @NamedQuery(name = "LineaFacturaMultimarca.findByDescuento", query = "SELECT l FROM LineaFacturaMultimarca l WHERE l.descuento = :descuento")})
public class LineaFacturaMultimarca implements Serializable {
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Column(name = "PVP")
    private BigDecimal pvp;
    @JoinColumn(name = "FACTURA", referencedColumnName = "ID_FACTURA_MULTIMARCA")
    @ManyToOne(optional = false)
    private FacturaMultimarca factura;
    @JoinColumn(name = "PRODUCTO_TALLA", referencedColumnName = "ID_PRODUCTO_TALLA")
    @ManyToOne(optional = false)
    private ProductoTalla productoTalla;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_LINEA_FACTURA_MULTIMARCA")
    private Integer idLineaFacturaMultimarca;
    @Basic(optional = false)
    @NotNull
    @Column(name = "CANTIDAD")
    private int cantidad;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Column(name = "COSTE")
    private BigDecimal coste;
    @Column(name = "DESCUENTO")
    private BigDecimal descuento;

    public LineaFacturaMultimarca() {
    }

    public LineaFacturaMultimarca(Integer idLineaFacturaMultimarca) {
        this.idLineaFacturaMultimarca = idLineaFacturaMultimarca;
    }

    public LineaFacturaMultimarca(Integer idLineaFacturaMultimarca, FacturaMultimarca factura, ProductoTalla productoTalla, int cantidad, BigDecimal coste) {
        this.idLineaFacturaMultimarca = idLineaFacturaMultimarca;
        this.factura = factura;
        this.productoTalla = productoTalla;
        this.cantidad = cantidad;
        this.coste = coste;
    }

    public Integer getIdLineaFacturaMultimarca() {
        return idLineaFacturaMultimarca;
    }

    public void setIdLineaFacturaMultimarca(Integer idLineaFacturaMultimarca) {
        this.idLineaFacturaMultimarca = idLineaFacturaMultimarca;
    }

    public FacturaMultimarca getFactura() {
        return factura;
    }

    public void setFactura(FacturaMultimarca factura) {
        this.factura = factura;
    }

    public ProductoTalla getProductoTalla() {
        return productoTalla;
    }

    public void setProductoTalla(ProductoTalla productoTalla) {
        this.productoTalla = productoTalla;
    }

    public int getCantidad() {
        return cantidad;
    }

    public void setCantidad(int cantidad) {
        this.cantidad = cantidad;
    }

    public BigDecimal getCoste() {
        return coste;
    }

    public void setCoste(BigDecimal coste) {
        this.coste = coste;
    }

    public BigDecimal getDescuento() {
        return descuento;
    }

    public void setDescuento(BigDecimal descuento) {
        this.descuento = descuento;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idLineaFacturaMultimarca != null ? idLineaFacturaMultimarca.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof LineaFacturaMultimarca)) {
            return false;
        }
        LineaFacturaMultimarca other = (LineaFacturaMultimarca) object;
        if ((this.idLineaFacturaMultimarca == null && other.idLineaFacturaMultimarca != null) || (this.idLineaFacturaMultimarca != null && !this.idLineaFacturaMultimarca.equals(other.idLineaFacturaMultimarca))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.LineaFacturaMultimarca[ idLineaFacturaMultimarca=" + idLineaFacturaMultimarca + " ]";
    }

    public BigDecimal getPvp() {
        return pvp;
    }

    public void setPvp(BigDecimal pvp) {
        this.pvp = pvp;
    }
}
